<template>
  <div>
    <tableComponents :pagination="{ currentPage, pageSize, total: list.all_num }" @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" @sendUserSearch="getUserSearch" :searchData="userSearchData" @toAdd="add" exportUrl="/api/admin/export/excel_out_user" :toUp="toUpName" :down="down" :isShow="visi" ref="tableComponents"> <template v-slot:headRight>
        <div class="fx head-right-icon">
          <p @click="clear_ewm_all">
            <i class="el-icon-close"></i>&nbsp;&nbsp;清空二维码
          </p>
        </div>
      </template>
      <template v-slot:table>
        <el-table ref="multipleTable" :data="list.data" v-loading="loading" stripe header-row-class-name="head_color" tooltip-effect="dark" style="width: 99.8%" @selection-change="handleSelectionChange">
          <el-table-column type="selection" class="tc" width="35"></el-table-column>

          <el-table-column label="会员" min-width="100" align="center">
            <template slot-scope="scope">
              <div class="tc">
                <img style="width: 50px; height: 50px" :src="imgError(scope.row.avatar)" class="user_img" />
                <span>{{ scope.row.rating_cn }}</span>
                <p style="font-size: 12px"> 
                  <span style="color: #999999">注册来源：</span>{{ scope.row.source || "其他" }}
                </p>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="会员信息" min-width="160">
            <template slot-scope="scope">
              <div class="user_table">
                <div>
                  <span>用户昵称：</span>
                  <small>{{ scope.row.nickname || "----" }}</small>
                </div>
                <div>
                  <span>会员账号：</span>
                  <small>{{ scope.row.username }}</small>
                  <el-tag effect="dark" type size="mini" color="#f56c6c" style="margin-left: 10px">
                    <small id="tjm_btn" style="color: white; font-weight: normal; cursor: pointer" @click="copy_tjm($event)">点击复制</small>
                  </el-tag>
                </div>
                <div>
                  <span>推荐人：</span>
                  <small>{{ scope.row.tid_cn || "----" }}</small>
                  <span v-if="scope.row.tid_cn != ''" @click="toUp(scope.row.username)" class="find_btn">查询上级</span>
                </div>
                <div>
                  <span>出局次数：</span>
                  <small>{{ scope.row.out_num || "0" }}</small>
                </div>

                <div>
                  <span>手机号：</span>
                  <small>{{ scope.row.tel || "----" }}</small>
                </div>
                <div v-if="
                    $store.state.plugin &&
                    $store.state.plugin.sxy &&
                    $store.state.plugin.sxy.is_open == 1 
                  ">
                  <span>商学院考试分数：</span>
                  <small>{{ Number(scope.row.discuss) || '---'}}</small>
                </div>
                <div v-if="is_open.xnbkj && is_open.xnbkj.is_open == 1">
                  <span>矿机等级：</span>
                  <small>{{scope.row.coin_rating_cn}}</small>
                </div>

                <div>
                  <span>注册时间：</span>
                  <small>{{ scope.row.created_time | getTimeFormat }}</small>
                </div>

                <div v-if="
                    scope.row.vip_time &&
                    scope.row.vip_time > 0 &&
                    Number(scope.row.vip_time) >
                      Number(JSON.stringify(new Date().getTime()).substr(0, 10))
                  ">
                  <span>到期时间：</span>
                  <small>{{ scope.row.vip_time | getTimeFormat }}</small>
                </div>

                <div v-if="
                    $store.state.plugin &&
                    $store.state.plugin.shbxt &&
                    $store.state.plugin.shbxt.is_open == 1 &&
                    scope.row.is_supplier == 1
                  ">
                  <span>供应商：</span>
                  <small>{{ scope.row.shop_title || "----" }}</small>
                </div>

                <div v-if="
                    $store.state.plugin &&
                    $store.state.plugin.gbfx &&
                    $store.state.plugin.gbfx.is_open == 1 &&
                    scope.row.is_agent > 0
                  ">
                  <span>代理商：</span>
                  <small>
                    {{ `${scope.row.agent_province || ''}${scope.row.agent_city || ''}${scope.row.agent_area || ''}${scope.row.agent_town || ''}`}}/
                    {{scope.row.is_agent == 4 ? "乡镇代理" : scope.row.is_agent == 3 ? "省级代理" : scope.row.is_agent == 2? "市级代理": scope.row.is_agent == 1 ? "区级代理" : "" }}
                  </small>
                </div>

                <div v-if="
                    $store.state.plugin &&
                    $store.state.plugin.gxgd &&
                    $store.state.plugin.gxgd.is_open == 1 &&
                    scope.row.is_shareholder == 1
                  ">
                  <span>股东权益：</span>
                  <small>{{scope.row.is_shareholder == 1 ? "单店股东" : scope.row.is_shareholder == 2 ? "全量股东": "---" }}</small>
                </div>

                <div>
                  <span>备注：</span>
                  <small>{{ scope.row.admin_remark }}</small>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="资金" min-width="100">
            <template slot-scope="scope">
              <div class="user_table">
                <div v-for="(item, x) in scope.row.reward_ar[1]" :key="x">
                  <span>{{ item.title }}：</span>
                  <small>{{ item.value }}</small>
                </div>
              </div>

            </template>
          </el-table-column>
          <el-table-column label="虚拟币" min-width="150" v-if="is_open.xnbkj && is_open.xnbkj.is_open != 0">
            <template slot-scope="scope">
              <div class="user_table">
                <div v-for="(item, i) in scope.row.reward_ar[0]" :key="i">
                  <span>{{ item.title }}：</span>
                  <small>{{ item.value }}</small>
                </div>
              </div>

            </template>
          </el-table-column>

          <el-table-column label="下级会员数" min-width="120">
            <template slot-scope="scope">
              <div class="user_table">
<!--                <div>-->
<!--                  <span>团队待释放总额:</span>-->
<!--                  <small>{{ scope.row.ttzdsf || 0 }}</small>-->
<!--                </div>-->
                <div v-if="is_open.xnbkj && is_open.xnbkj.is_open != 0">
                  <span> 直推/会员/虚拟币:</span>
                  <small>{{ scope.row.ynumber || 0 }}/{{ scope.row.yvip || 0 }}/{{scope.row.coin_yvip || 0}}</small>
                  <span v-if="scope.row.ynumber != 0" @click="toUp(scope.row.username, 'down', scope.row.ynumber)" class="find_btn">查询下级</span>
                </div>
                <div v-else style>
                  <span>直推注册/团队注册:</span>
                  <small>{{ scope.row.ynumber || 0 }}/{{scope.row.znumber || 0}}</small>
                  <span v-if="scope.row.ynumber != 0" @click="toUp(scope.row.username, 'down', scope.row.ynumber)" class="find_btn">查询下级</span>
                </div>
                <div>
                  <span>直推会员/团队会员:</span>
                  <small>{{ scope.row.yvip || 0 }}/{{ scope.row.zvip || 0 }}</small>
                </div>
                <div>
                  <span>直推业绩:&nbsp;&nbsp;</span>
                  <small>{{ scope.row.ysales | toFixedNum }}</small>
                </div>
<!--                <div>-->
<!--                  <span>团队业绩:&nbsp;&nbsp;</span>-->
<!--                  <small>{{ scope.row.zsales | toFixedNum }}</small>-->
<!--                </div>-->
                <div>
                  <span>商城累计消费:&nbsp;&nbsp;</span>
                  <small>{{ scope.row.buy | toFixedNum }}</small>
                </div>

                <div v-if="scope.row.staff_name">
                  <span>所属员工：</span>
                  <small>{{ scope.row.staff_name}}</small>
                </div>
                <div v-if="is_open.xnbkj && is_open.xnbkj.is_open != 0">
                  <span>虚拟币累计消费:</span>
                  <small v-if="is_open.xnbkj && is_open.xnbkj.is_open != 0">{{scope.row.coin_buy || 0}}</small>
                </div>

                <div v-if="is_open.xnbkj && is_open.xnbkj.is_open != 0">
                  <span>虚拟币累计佣金:&nbsp;&nbsp;</span>
                  <small>{{ scope.row.sum_coin || 0}}</small>
                </div>
                <div v-for="(item, i) in scope.row.made" :key="i">
                  <span>{{ item.title }}:&nbsp;&nbsp;</span>
                  <small>{{ item.value }}</small>
                </div>
                <div v-if="is_open.dapp && is_open.dapp.is_open == 1">
                  <span>dapp累计入单：</span>
                  <small>{{ scope.row.dapp_rating || "---"}}</small>
                </div>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="跟进记录" min-width="140" v-if="
              $store.state.plugin &&
              $store.state.plugin.qyyy &&
              $store.state.plugin.qyyy.is_open == 1
            ">
            <template slot-scope="scope">
              <div class="user_table">
                <div>
                  <span>客户来源:&nbsp;&nbsp;</span>
                  <small>{{ scope.row.clue_source || "其他来源" }}</small>
                  <el-tag effect="dark" type size="mini" style="margin-left: 10px" v-if="scope.row.record.created_time>0">
                    <small id="tjm_btn" style="color: white; font-weight: normal; cursor: pointer" @click="lookSchedule(scope.row.id)">跟进记录</small>
                  </el-tag>
                </div>
                <div>
                  <span>当前跟进人:&nbsp;&nbsp;</span>
                  <small>{{ scope.row.operator_cn || "暂无当前跟进人" }}</small>
                </div>
                <div>
                  <span>最后跟进人:&nbsp;&nbsp;</span>
                  <small>{{ scope.row.record.name || "----" }}</small>
                </div>
                <div>
                  <span>最后跟进时间:&nbsp;&nbsp;</span>
                  <small>{{
                    scope.row.record.created_time || 0 | getTimeFormat
                  }}</small>
                </div>

                <div>
                  <span>最后跟进内容:&nbsp;&nbsp;</span>
                  <small>{{ scope.row.record.record || "----" }}</small>
                </div>

                <div>
                  <el-tag v-for="item in scope.row.quick_label" :key="item" type="warning" size="mini" v-show="item" style="margin: 5px 5px 0 0">
                    {{ item }}
                  </el-tag>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="激活" min-width="65">
            <template slot-scope="scope">
              <el-switch class="zdySwith" :width="82" v-model="scope.row.show" active-color="#1aad19" inactive-color="#ffffff" active-text="on" inactive-text="off" active-value="1" @change="handleSwitch($event, scope.row.id)" inactive-value="0"></el-switch>
            </template>
          </el-table-column>

          <el-table-column label="操作" min-width="140">
            <template slot-scope="scope">
              <el-row class="myblank">
                <el-button type="primary" plain size="mini" @click="getUserInfo(scope.row.id)">
                  详情
                </el-button>

                <el-dropdown @command="handleCommand" class="user-button" v-if="
                    open_btn.indexOf('编辑') >= 0 ||
                    open_btn.indexOf('删除') >= 0 ||
                    open_btn.indexOf('修改推荐人') >= 0 ||
                    open_btn.indexOf('发送客服消息') >= 0 ||
                    open_btn.indexOf('发送站内信') >= 0
                  ">
                  <el-button plain type="primary" size="mini">
                    操作
                    <i class="el-icon-arrow-down el-icon--right"></i>
                  </el-button>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-if="open_btn.indexOf('编辑') >= 0" :command="toObj(scope.row, '编辑')">编辑</el-dropdown-item>
                    <el-dropdown-item v-if="open_btn.indexOf('删除') >= 0" :command="toObj(scope.row, '删除')">删除</el-dropdown-item>
                    <el-dropdown-item v-if="open_btn.indexOf('修改推荐人') >= 0" :command="toObj(scope.row, '修改推荐人')">修改推荐人</el-dropdown-item>
                    <el-dropdown-item v-if="open_btn.indexOf('发送客服消息') >= 0" :command="toObj(scope.row, '发送客服消息')">通知他</el-dropdown-item>
                    <el-dropdown-item v-if="open_btn.indexOf('发送站内信') >= 0" :command="toObj(scope.row, '发送站内信')">发送站内信</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>

                <el-dropdown @command="handleCommand" v-if="
                    open_btn.indexOf('重置二维码') >= 0 ||
                    open_btn.indexOf('微信推广码') >= 0 ||
                    open_btn.indexOf('H5推广码') >= 0 ||
                    open_btn.indexOf('小程序二维码') >= 0 ||
                    open_btn.indexOf('解除绑定') >= 0
                  ">
                  <el-button plain type="warning" size="mini">
                    推广码
                    <i class="el-icon-arrow-down el-icon--right"></i>
                  </el-button>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-if="open_btn.indexOf('重置二维码') >= 0" :command="toObj(scope.row, '重置二维码')">重置二维码</el-dropdown-item>
                    <el-dropdown-item v-if="open_btn.indexOf('微信推广码') >= 0" :command="toObj(scope.row, '微信推广码')">微信推广码</el-dropdown-item>
                    <el-dropdown-item v-if="open_btn.indexOf('H5推广码') >= 0" :command="toObj(scope.row, 'H5推广码')">H5推广码</el-dropdown-item>
                    <el-dropdown-item v-if="open_btn.indexOf('小程序二维码') >= 0" :command="toObj(scope.row, '小程序推广码')">小程序推广码</el-dropdown-item>
                    <el-dropdown-item v-if="open_btn.indexOf('解除绑定') >= 0" :command="toObj(scope.row, '解除绑定')">解除绑定</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>

                <el-dropdown @command="handleCommand" class="user-button" v-if="
                    open_btn.indexOf('重置密码') >= 0 ||
                    open_btn.indexOf('重置支付密码') >= 0
                  ">
                  <el-button plain type="warning" size="mini">
                    安全
                    <i class="el-icon-arrow-down el-icon--right"></i>
                  </el-button>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-if="open_btn.indexOf('重置密码') >= 0" :command="toObj(scope.row, '重置密码')">重置密码</el-dropdown-item>
                    <el-dropdown-item :command="toObj(scope.row, '重置支付密码')" v-if="open_btn.indexOf('重置支付密码') >= 0">重置支付密码</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>

                <el-dropdown @command="handleCommand" class="user-button" v-if="open_btn.indexOf('账户充减') >= 0">
                  <el-button plain type="primary" size="mini">
                    资金
                    <i class="el-icon-arrow-down el-icon--right"></i>
                  </el-button>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-if="open_btn.indexOf('账户充减') >= 0" :command="toObj(scope.row, '账户充减')">账户充减</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>

                <el-dropdown @command="handleCommand" class="user-button" v-if="
                    open_btn.indexOf('设等级') >= 0 ||
                    open_btn.indexOf('代理商') >= 0 ||
                    open_btn.indexOf('供应商') >= 0 ||
                    open_btn.indexOf('申请主播') >= 0 ||
                    open_btn.indexOf('股东') >= 0
                  ">
                  <el-button plain type="primary" size="mini">
                    身份
                    <i class="el-icon-arrow-down el-icon--right"></i>
                  </el-button>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-if="open_btn.indexOf('设等级') >= 0" :command="toObj(scope.row, '设置等级')">设置等级</el-dropdown-item>

                    <el-dropdown-item v-if="
                        is_open.gbfx &&
                        is_open.gbfx.is_open == 1 &&
                        open_btn.indexOf('代理商') >= 0
                      " :command="toObj(scope.row, '设为代理')">{{
                        scope.row.is_agent == 0 ? "设为代理" : "编辑代理"
                      }}</el-dropdown-item>

                    <el-dropdown-item v-if="
                        is_open.shbxt &&
                        is_open.shbxt.is_open == 1 &&
                        open_btn.indexOf('供应商') >= 0
                      " :command="toObj(scope.row, '设为供应商')">{{
                        scope.row.is_supplier == 0 ? "设为供应商" : "编辑供应商"
                      }}</el-dropdown-item>
                    <el-dropdown-item v-if="
                        is_open.zbcj &&
                        is_open.zbcj.is_open == 1 &&
                        open_btn.indexOf('申请主播') >= 0
                      " :command="toObj(scope.row, '设置主播')">设置主播</el-dropdown-item>
					  
					  <el-dropdown-item :command="toObj(scope.row, '设置券商')">设置券商</el-dropdown-item>
					  <el-dropdown-item :command="toObj(scope.row, '暂停发放')">暂停发放</el-dropdown-item>
                    <el-dropdown-item v-if="
                        is_open.gxgd &&
                        is_open.gxgd.is_open == 1 &&
                        open_btn.indexOf('股东') >= 0
                      " :command="toObj(scope.row, '股东')">{{
                        scope.row.is_shareholder == 0 ? "设为股东" : "编辑股东"
                      }}</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </el-row>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </tableComponents>

    <el-drawer :visible.sync="show_user" direction="rtl" size="40%" class="user_edit_drawer">
      <UserEdit @parent="reload" :editId="editId" v-if="show_user" :open_btn="open_btn"></UserEdit>
    </el-drawer>

    <!--编辑会员-->
    <UserReal @parent="reload" :show.sync="show_real" :editId="editId" :clickNum="clickNum_user"></UserReal>
    <!--实名认证-->
    <CollectionsEdit :nowsel="collectionsel" @parent="reload" :show.sync="show" :editId="editId" :clickNum="clickNum"></CollectionsEdit>
    <!--收款信息-->
    <RatingEdit @parent="reload" :show.sync="show_rating" :editId="editId" :clickNum="clickNum_rating"></RatingEdit>
    <!--设等级-->
    <RechargeEdit @parent="reload" :show.sync="show_recharge" :editId="editId" :clickNum="clickNum_recharge" :editUser="editUser"></RechargeEdit>
    <!--充值-->
    <ChangetidEdit @parent="reload" :show.sync="show_changetid" :editId="editId" :clickNum="clickNum_changetid" :editUser="editUser"></ChangetidEdit>
    <!--修改推荐人-->
    <LetterEdit @parent="reload" :show.sync="show_letter" :editId="editId" :clickNum="clickNum_letter" :editUser="editUser"></LetterEdit>
    <!--发送站内信-->
    <WxewmEdit @parent="reload" :show.sync="show_wxewm" :editId="editId" :clickNum="clickNum_wxewm" :editUser="editUser"></WxewmEdit>
    <!--微信二维码-->
    <WyewmEdit @parent="reload" :show.sync="show_wyewm" :editId="editId" :clickNum="clickNum_wyewm" :editUser="editUser" width="100px"></WyewmEdit>
    <!--网页二维码-->
    <XcyewmEdit @parent="reload" :show.sync="show_xcyewm" :editId="editId" :clickNum="clickNum_xcyewm" :editUser="editUser" width="100px">
    </XcyewmEdit>
    <!-- XcyewmEdit 小程序 -->

    <SupplierEdit @parent="reload" :show.sync="show_supplier" :editId="editId" :clickNum="clickNum_supplier" :editUser="editUser" :realname="realname" :shoptitle="shoptitle" :is_supplier="isSupplier" :row="row"></SupplierEdit>

    <!--收款信息-->
    <liveEdit @parent="reload" :show.sync="show_live" :editId="editId" :clickNum="clickNum_live" :editUser="editUser" :row="row"></liveEdit>
	<!-- 券商 -->
    <quanEdit @parent="reload" :show.sync="show_quan" :editId="editId" :clickNum="clickNum_quan" :editUser="editUser" :row="row"></quanEdit>
    <stopEdit @parent="reload" :show.sync="show_stop" :editId="editId" :clickNum="clickNum_stop" :editUser="editUser" :row="row"></stopEdit>
    <!-- 编辑与加入股东 -->
    <shareholderEdit @parent="reload" :show.sync="show_shareholder" :editId="editId" :clickNum="clickNum_live" :editUser="editUser" :row="row"></shareholderEdit>

    <!--编辑与加入供应商-->

    <el-dialog :close-on-click-modal="false" title="添加会员" :modal-append-to-body="false" :visible.sync="addvisible" class="tl size_13" width="800px">
      <el-form :model="data" :rules="dataYZ" ref="data" class="mar_top" label-width="120px">
        <!-- <el-form-item label="会员账号" prop="username">
                    <el-col :span="4">
                        <el-input placeholder v-model="data.username" style="width:220px" clearable></el-input>
                    </el-col>
        </el-form-item>-->

        <el-form-item label="头像" prop="avatar">
          <el-col :span="18" class="tl">
            <el-input v-model="data.avatar" autocomplete="off" clearable class="mar_bottom_5" disabled></el-input>
            <uploadpic :piclink="data.avatar" :width="150" :height="150" :real_width="150" :real_height="150" :is_more="false" @send_pic="onSuccess">
            </uploadpic>
          </el-col>
        </el-form-item>
        <el-form-item label="区号" prop>
          <el-col :span="12">
            <el-input placeholder v-model="data.quhao" clearable></el-input>
          </el-col>
        </el-form-item>

        <el-form-item label="电话" prop>
          <el-col :span="12">
            <el-input min="11" max="11" placeholder v-model="data.tel" clearable></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="昵称" prop>
          <el-col :span="12">
            <el-input placeholder v-model="data.nickname" clearable></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="登录密码" prop="password">
          <el-col :span="12">
            <el-input placeholder show-password v-model="data.password" clearable></el-input>
          </el-col>
        </el-form-item>

        <el-form-item label="支付密码" prop="pay_password">
          <el-col :span="12">
            <el-input placeholder show-password v-model="data.pay_password" clearable></el-input>
          </el-col>
        </el-form-item>

        <div class="mar_bottom_15">
          <span class="sizeColor size_13 sp_style"></span>
          <el-button :loading="$store.state.isLoading" size="medium" type="primary" @click.prevent="addUpdate('data')">确定</el-button>
        </div>
      </el-form>
    </el-dialog>

    <!-- 供应商操作 -->

    <el-dialog :close-on-click-modal="false" title="代理商" :modal-append-to-body="false" :visible.sync="showAgent" class="tl size_13" width="800px">
      <el-form :model="agent" ref="data" class="mar_top" label-width="120px">
        <el-form-item label="代理商" prop="username">
          <el-col :span="24">
            <el-radio v-model="agent.is_agent" @change="changeRadio" label="0">不是</el-radio>
            <el-radio v-model="agent.is_agent" @change="changeRadio" label="4">乡镇</el-radio>
            <el-radio v-model="agent.is_agent" @change="changeRadio" label="1">区代</el-radio>
            <el-radio v-model="agent.is_agent" @change="changeRadio" label="2">市代</el-radio>
            <el-radio v-model="agent.is_agent" @change="changeRadio" label="3">省代</el-radio>
          </el-col>
        </el-form-item>
        <el-form-item label="代理地区" prop v-if="showCity && agent.is_agent > 0">
          <el-col :span="12">
            <city-cascader :placeholder="selectedOptions.join('-')" :level="
                agent.is_agent == 4
                  ? 3
                  : agent.is_agent == 3
                  ? 0
                  : agent.is_agent == 2
                  ? 1
                  : agent.is_agent == 1
                  ? 2
                  : 0
              " @change="handleChange" :selected="selectedOptions" />
          </el-col>
        </el-form-item>

        <div class="mar_bottom_15">
          <span class="sizeColor size_13 sp_style"></span>
          <el-button :loading="$store.state.isLoading" size="medium" type="primary" @click.prevent="subAgent">确定</el-button>
        </div>
      </el-form>
    </el-dialog>

    <el-dialog :close-on-click-modal="false" title="添加关联账户" :modal-append-to-body="false" :visible.sync="showAddPhoneDio" class="tl size_13" width="800px">
      <user-relation-phone />
    </el-dialog>
    <el-dialog :close-on-click-modal="false" title="添加通知消息" :modal-append-to-body="false" :visible.sync="showService" class="tl size_13" width="800px">
      <serviceAdd :service="service" :isUser="true" @openThis="getOpenThis"></serviceAdd>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" title="解除绑定" :modal-append-to-body="false" :visible.sync="show_reset" class="tl size_13" width="1200px">
      <userReset :reset_id="reset_id" @reset_success="rec_success"></userReset>
    </el-dialog>

    <el-dialog :close-on-click-modal="false" title="跟进记录" :visible.sync="progressShow" class="tl size_13" width="1200px">
      <el-table ref="multipleTable" :data="progresslist" border tooltip-effect="dark" style="width: 100%">
        <el-table-column label="等级" min-width="160">
          <template slot-scope="scope">
            {{ scope.row.rating_cn || "---" }}
          </template>
        </el-table-column>
        <el-table-column label="昵称" min-width="160">
          <template slot-scope="scope">
            {{ scope.row.nickname || "---" }}
          </template>
        </el-table-column>
        <el-table-column label="用户名" min-width="160">
          <template slot-scope="scope">
            {{ scope.row.username || "---" }}
          </template>
        </el-table-column>
        <el-table-column label="跟进备注" min-width="160">
          <template slot-scope="scope">
            {{ scope.row.record }}
          </template>
        </el-table-column>
        <el-table-column label="跟进时间" min-width="130">
          <template slot-scope="scope">
            {{ scope.row.created_time | getTimeFormat }}
          </template>
        </el-table-column>
      </el-table>

    </el-dialog>

  </div>
</template>
<script>
import CollectionsEdit from "@/components/user/collections_edit.vue"; //收款信息
import UserEdit from "@/components/user/user_edit.vue"; //编辑会员
import UserReal from "@/components/user/user_real.vue"; //编辑会员
import RatingEdit from "@/components/user/user_rating.vue"; //设等级
import RechargeEdit from "@/components/user/user_recharge.vue"; //充值
import ChangetidEdit from "@/components/user/user_changetid.vue"; //修改推荐人
import LetterEdit from "@/components/user/user_letter.vue"; //发送站内信
import WxewmEdit from "@/components/user/user_wxewm.vue"; //微信二维码
import WyewmEdit from "@/components/user/user_wyewm.vue"; //网页二维码

import XcyewmEdit from "@/components/user/user_xcyewm.vue"; //网页二维码
import liveEdit from "@/components/user/user_live.vue"; //主播设置
import quanEdit from "@/components/user/user_quan.vue"; //主播设置
import stopEdit from "@/components/user/user_stop.vue"; //主播设置
import shareholderEdit from "@/components/user/user_shareholder.vue"; //编辑与加入股东

import SupplierEdit from "@/components/user/user_supplier.vue"; //编辑与加入供应商
import cityCascader from "@/components/currency/cityCascader/cityCascader";
import userRelationPhone from "./userRelationPhone/userRelationPhone";
import serviceAdd from "./service/servideAdd";
import userReset from "@/components/user/user_reset";
import uploadpic from "@/components/page/pic/up_pic";
import { userSearchData } from "../../assets/js/searchData/searchData"; //引入搜索的数据
export default {
  data() {
    return {
      progressShow: false,
      progresslist: [],
      collectionsel: "",
      userSearchData: userSearchData,
      reset_id: "",
      show_reset: false,
      open_btn: [],
      toUpName: "",
      down: "",
      showAgent: false,
      showAddPhoneDio: false,
      row: {},
      agent: {
        is_agent: "0",
        agent_province: "",
        agent_city: "",
        agent_area: "",
        agent_town: "",
      },
      options: [],
      optionProps: {
        value: "y",
        label: "t",
        children: "z",
        checkStrictly: true,
      },
      selectedOptions: [],
      is_open: this.$store.state.plugin || {},
      show: false,
      show_user: false,
      show_real: false,
      show_rating: false,
      show_recharge: false,
      show_changetid: false,
      show_letter: false,
      show_wxewm: false,
      show_wyewm: false,
      show_supplier: false,
      show_live: false,
      show_quan: false,
	  show_stop: false,
      show_shareholder: false,
      list: [],
      allPage: 0,
      allNum: 0,
      pageSize: 10,
      currentPage: 1,
      editId: "",
      editUser: "",
      realname: "",
      shoptitle: "",
      isSupplier: "",
      multipleSelection: "",
      arr: [],
      visible: false,
      clickNum: 0,
      updataIndex: "",
      clickNum_user: 0,
      clickNum_rating: 0,
      clickNum_recharge: 0,
      clickNum_changetid: 0,
      clickNum_letter: 0,
      clickNum_wxewm: 0,
      clickNum_wyewm: 0,
      clickNum_xcyewm: 0,
      clickNum_supplier: 0,
      clickNum_live: 0,
      clickNum_quan: 0,
	  clickNum_stop: 0,
      searchAll: {},
      value: "",
      addvisible: false,
      show_xcyewm: false,
      data: {
          avatar:"",
        // username: "",
        quhao: "86",
        tel: "",
        password: "",
        pay_password: "",
      },
      loading: false,
      dataYZ: {
        // username: [
        //     { required: true, message: "请输入会员账号", trigger: "blur" }
        // ],
        password: [
          { required: true, message: "请输入登录密码", trigger: "blur" },
        ],
      },
      visi: true,
      showCity: true,
      service: {
        id: "",
        username: "",
        types: 1,
      },
      showService: false,
    };
  },
  components: {
    CollectionsEdit,
    UserEdit,
    RatingEdit,
    RechargeEdit,
    ChangetidEdit,
    LetterEdit,
    WxewmEdit,
    WyewmEdit,
    SupplierEdit,
    cityCascader,
    userRelationPhone,
    serviceAdd,
    UserReal,
    XcyewmEdit,
    userReset,
    liveEdit,
    quanEdit,
	stopEdit,
    shareholderEdit,
    uploadpic
  },

  methods: {
    onSuccess(pic) {
      this.$set(this.data, "avatar", pic);
    },
    lookSchedule(id) {
      var params = {};
      params.id = id;
      this.$api.getStation.staff_record_lists(params).then((res) => {
        if (res.data.code == 200) {
          this.progressShow = true;
          this.progresslist = res.data.result.data;
        } else {
          this.$fnc.alertError(res.data.code_desc, res.data.result);
        }
      });
      this.loading_2 = false;
    },
    toObj(obj, str) {
      obj = obj || {};
      obj.commandStr = str;
      return JSON.parse(JSON.stringify(obj));
    },
    handleCommand(command) {
      var str = command.commandStr;
      switch (str) {
        case "详情":
          this.getUserInfo(command.id);
          break;
        case "实名认证":
          this.showreal_dia(command.id);
          break;
        case "收款信息zfb":
          this.collectionsel = "zfb";
          this.showCollectDialog(command.id);
          break;
        case "收款信息wx":
          this.collectionsel = "wx";
          this.showCollectDialog(command.id);
          break;
        case "收款信息bank":
          this.collectionsel = "bank";
          this.showCollectDialog(command.id);
          break;
        case "编辑":
          this.showEditDialog(command.id);
          break;
        case "删除":
          this.deleteNew(command.id);
          break;
        case "修改推荐人":
          this.showchangetidDialog(command.id, command.username);
          break;
        case "发送客服消息":
          this.checkShowService(command.id, command.username, command.nickname);
          break;
        case "重置二维码":
          this.resetEwm(command.id, command.username);
          break;
        case "微信推广码":
          this.resetWxEwm(command.id, command.username);
          break;
        case "H5推广码":
          this.resetWyEwm(command.id, command.username);
          break;
        case "小程序推广码":
          this.resetXcyEwm(command.id, command.username);
          break;
        case "解除绑定":
          this.reset_btn(command.id);
          break;
        case "重置密码":
          this.resetPassword(command.id, command.username);
          break;
        case "重置支付密码":
          this.resetPayPassword(command.id, command.username);
          break;
        case "账户充减":
          this.showRechargeDialog(command.id, command.username);
          break;
        case "设置等级":
          this.showRatingDialog(command.id);
          break;
        case "设为代理":
          this.editAgent(command);
          break;
        case "设为供应商":
          this.showSupplierDialog(command);
          break;
        case "发送站内信":
          this.showLetterDialog(command.id, command.username, command.nickname);
          break;
        case "设置主播":
          this.setlive(command);
        case "设置券商":
          this.setquan(command);
          break;
        case "暂停发放":
          this.setstop(command);
          break;
        case "股东":
          this.setShareholder(command);
          break;
        default:
          break;
      }
    },
    rec_success() {
      this.reset_id = "";
      this.show_reset = false;
      this.getNewsAll(this.searchAll);
    },
    reset_btn(id) {
      this.reset_id = id;
      this.show_reset = true;
    },
    get_admin() {
      var params = {};
      params.id = localStorage.getItem("adminuid");
      this.$api.getUser.getHeadUserInfo(params).then((res) => {
        if (res.data.code == 200) {
          var arr = [];
          if (
            res.data.result.role_con_user != "" &&
            res.data.result.role_con_user
          ) {
            arr = res.data.result.role_con_user.split("@");
            arr = arr.filter((item) => {
              return item != "";
            });
            this.open_btn = arr;
          } else {
            this.open_btn = [
              "详情",
              "编辑",
              "删除",
              "实名认证",
              "收款信息",
              "设等级",
              "账户充减",
              "修改推荐人",
              "发送客服消息",
              "重置密码",
              "重置支付密码",
              "重置二维码",
              "微信推广码",
              "H5推广码",
              "小程序二维码",
              "解除绑定",
            ];
            if (this.is_open.gbfx && this.is_open.gbfx.is_open == 1) {
              this.open_btn.push("代理商");
            }
            if (this.is_open.shbxt && this.is_open.shbxt.is_open == 1) {
              this.open_btn.push("供应商");
            }
            if (this.is_open.zbcj && this.is_open.zbcj.is_open == 1) {
              this.open_btn.push("申请主播");
            }
            if (this.is_open.gxgd && this.is_open.gxgd.is_open == 1) {
              this.open_btn.push("股东");
            }
          }
        }
      });
    },
    toUp(tid, st, index) {
      this.$refs.tableComponents.clearSearch();
      if (tid) {
        if (st == "down") {
          if (index == 0) {
            this.$swal("无下级级推荐人", "", "error");
          } else {
            this.getUserSearch({ t_username: tid });
            this.down = tid;
          }
        } else {
          this.getUserSearch({ u_username: tid });
          this.toUpName = tid;
        }
      } else {
        this.$swal("无上级推荐人", "", "error");
      }
    },
    export_user() {
      this.$fnc.postExcelFile({}, "/api/admin/export/excel_out_user");
    },
    setShareholder(val) {
      this.show_shareholder = true;
      this.editId = val.id;
      this.clickNum_live++;
      this.row = val;
      this.editUser = val.username;
    },
    setlive(val) {
      this.show_live = true;
      this.editId = val.id;
      this.clickNum_live++;
      this.row = val;
      this.editUser = val.username;
    },
    setquan(val) {
      this.show_quan = true;
      this.editId = val.id;
      this.clickNum_quan++;
      this.row = val;
      this.editUser = val.username;
    },
    setstop(val) {
      this.show_stop = true;
      this.editId = val.id;
      this.clickNum_stop++;
      this.row = val;
      this.editUser = val.username;
    },
    showreal_dia(id) {
      this.show_real = true;
      this.editId = id;
      this.clickNum_user++;
    },
    getOpenThis(bool) {
      if (bool) {
        this.getNewsAll(this.searchAll);
      } else {
        this.showService = false;
      }
    },
    checkShowService(id, username, nickname) {
      this.showService = true;
      this.service.id = id;
      this.service.username = username;
      this.service.nickname = nickname;
    },
    showAddPhone(id) {},
    changeRadio() {
      this.showCity = false;
      setTimeout(() => {
        this.showCity = true;
      }, 500);
    },
    clear_ewm_all() {
      this.$swal({
        title: "您确定要清空全部二维码吗",
        text: "清空后将无法恢复，请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我要删除",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          this.$api.getUser.clear_all_ewm({}).then((res) => {
            if (res.data.code == 200) {
              this.getNewsAll();
              this.$swal("清空成功！", "您已经全部清空了。", "success");
            } else {
              this.$swal(res.data.result, "error");
            }
          });
        }
      });
    },
    subAgent() {
      this.showAgent = false;
      var params = this.agent || {};
      this.$api.getUser.editAgent(params).then((res) => {
        if (res.data.code == 200) {
          this.$fnc.alertSuccess("操作成功");
          this.getNewsAll(this.searchAll);
        }
      });
    },
    handleChange(value) {
      this.agent.agent_province = "";
      this.agent.agent_city = "";
      this.agent.agent_area = "";
      this.agent.agent_town = "";
      if (value) {
        for (var i = 0; i < value.length; i++) {
          if (i == 0) this.agent.agent_province = value[i];
          if (i == 1) this.agent.agent_city = value[i];
          if (i == 2) this.agent.agent_area = value[i];
          if (i == 3) this.agent.agent_town = value[i];
        }
      }
    },
    editAgent(item) {
      this.showAgent = true;
      this.agent.id = item.id;
      this.agent.is_agent = item.is_agent;
      this.agent.agent_province = item.agent_province;
      this.agent.agent_city = item.agent_city;
      this.agent.agent_area = item.agent_area;
      this.agent.agent_town = item.agent_town;
      this.selectedOptions = [
        item.agent_province,
        item.agent_city,
        item.agent_area,
        item.agent_town,
      ];
    },
    copy_tjm($event) {
      var dom = $event.currentTarget.parentElement.previousElementSibling;
      var span = dom.innerText;
      var oInput = document.createElement("input");
      oInput.value = span;
      document.body.appendChild(oInput);
      oInput.select();
      document.execCommand("Copy");
      oInput.className = "oInput";
      oInput.style.display = "none";
      this.$fnc.alertSuccess("复制成功");
    },
    searcxiaji(id) {
      this.visi = false;
      this.searchAll = { tid: id };
      this.pageSize = 10;
      this.currentPage = 1;
      this.$router.push(this.$route.path + "?page=" + 1);
      this.getNewsAll(this.searchAll);
      this.$nextTick(() => {
        this.visi = true;
      });
    },
    addUpdate(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.addvisible = false;
          var params = {};
          params = this.data;
          this.$api.getUser.addUser(params).then((res) => {
            if (res.data.code == 200) {
              this.$fnc.alertSuccess({ text: "添加成功" });
              this.getNewsAll(this.searchAll);
            } else {
              this.$fnc.alertError(res.data.result);
            }
          });
        }
      });
    },
    add() {
      this.addvisible = true;
    },
    isHasImg(pathImg) {
      var ImgObj = new Image();
      ImgObj.src = pathImg;
      if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {
        return true;
      } else {
        return false;
      }
    },
    getUserSearch(obj) {
      this.currentPage = 1;
      this.searchAll = obj;
      this.getNewsAll();
    },
    getUserInfo(id) {
      this.editId = id;
      this.show_user = true;

      // let routeData = this.$router.resolve({
      //   path: "/index/user/user_info",
      //   query: { id: id, cate_id: cate_id, title: ti },
      // });
      // window.open(routeData.href, "_blank");
    },
    imgError(item) {
      if (!item) {
        return require("../../assets/img/default_head.png");
      }
      if (item.indexOf("http") >= 0) {
        return item;
      } else if (item.indexOf("api") >= 0) {
        return item;
      } else {
        return "/api/" + item;
      }
    },
    getNewsAll() {
      this.loading = true;
      var params = {};
      params = JSON.parse(JSON.stringify(this.searchAll));
      params.page = this.currentPage || 1;
      params.page_size = this.pageSize || "";
      for (var i in params) {
        if (!params[i]) {
          params[i] = "";
        }
      }
      var query = JSON.parse(JSON.stringify(this.queryObj));
      var obj = Object.assign(query, params);
      this.$api.getUser.getUserList(obj).then((res) => {
        if (res.data.code == 200 && res.data.status == 1) {
          this.list = res.data.result;
        } else {
          this.$fnc.alertError(res.data.code_desc, res.data.result);
        }
        setTimeout(() => {
          this.loading = false;
        }, 200);
      });
    },
    handleSizeChange(val) {
      this.currentPage = 1;
      this.pageSize = val;
      this.getNewsAll();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getNewsAll();
    },
    handleSwitch(val, id) {
      //审核
      var params = {};
      params["id"] = id;
      val == true ? (params["show"] = 1) : (params["show"] = 0);
      this.$api.getUser.userlock(params).then((res) => {
        // this.getNewsAll();
      });
    },
    handleSelectionChange(val) {
      //多选框赋值
      this.multipleSelection = val;
    },
    delSelection() {
      //删除
      this.$swal({
        title: "您确定要删除选中信息吗",
        text: "删除后将无法恢复，请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我要删除",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          var str = "";
          for (var i in this.multipleSelection) {
            str += this.multipleSelection[i].id + "@";
          }
          str = str.slice(0, -1);
          var data = { id_str: str };
          this.$api.getUser.userDel(data).then((res) => {
            if (res.data.code == 200) {
              this.getNewsAll();
            } else {
              this.$swal(res.data.result, "error");
            }
          });
        }
      });
    },
    deleteNew(id) {
      this.$swal({
        title: "您确定要删除这条信息吗",
        text: "删除后将无法恢复，请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我要删除",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          var data = { id_str: id };
          this.$api.getUser.userDel(data).then((res) => {
            if (res.data.code == 200) {
              this.$swal("删除成功！", "您已经删除了这条信息。", "success");
              this.getNewsAll();
            } else {
              this.$swal(res.data.result, "error");
            }
          });
        }
      });
    },
    resetPassword(id, username) {
      this.$swal({
        title: "确认后当前会员的密码将会重置",
        text: "请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确认，我要重置",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          var data = { username: username, id: id };
          this.$api.getUser.userResetPassword(data).then((res) => {
            if (res.data.code == 200) {
              this.$swal("新密码为" + res.data.result, "重置成功！", "success");
            } else {
              this.$swal("重置失败！", "出错啦！", "success");
            }
          });
        }
      });
    },
    resetPayPassword(id, username) {
      this.$swal({
        title: "当前会员的支付密码将会重置",
        text: "请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确认，我要重置",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          var data = { username: username, id: id };
          this.$api.getUser.userResetPayPassword(data).then((res) => {
            if (res.data.code == 200) {
              this.$swal(
                "重置支付密码为" + res.data.result,
                "重置成功！",
                "success"
              );
            } else {
              this.$swal("重置失败！", "出错啦！", "success");
            }
          });
        }
      });
    },
    resetEwm(id, username) {
      this.$swal({
        title: "如果您确认后，当前会员的二维码会清空，会员可以重新获取",
        text: "请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确认，我要重置",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          var data = { username: username, id: id };
          this.$api.getUser.userResetEwm(data).then((res) => {
            if (res.data.code == 200) {
              this.$swal("该会员二维码已清空", "重置成功！", "success");
            } else {
              this.$swal("重置失败！", "出错啦！", "success");
            }
          });
        }
      });
    },
    resetWxEwm(id) {
      this.show_wxewm = true;
      this.editId = id;
      this.clickNum_wxewm++;
    },
    resetWyEwm(id) {
      this.show_wyewm = true;
      this.editId = id;
      this.clickNum_wyewm++;
    },
    resetXcyEwm(id) {
      this.show_xcyewm = true;
      this.editId = id;
      this.clickNum_xcyewm++;
    },
    showCollectDialog(id) {
      this.show = true;
      this.editId = id;
      this.clickNum++;
    },

    showEditDialog(id) {
      this.show_user = true;
      this.editId = id;
      this.clickNum_user++;
    },
    showRatingDialog(id) {
      this.show_rating = true;
      this.editId = id;
      this.clickNum_rating++;
    },
    showRechargeDialog(id, u_name) {
      this.show_recharge = true;
      this.editId = id;
      this.editUser = u_name;
      this.clickNum_recharge++;
    },
    showchangetidDialog(id, u_name) {
      this.show_changetid = true;
      this.editId = id;
      this.editUser = u_name;
      this.clickNum_changetid++;
    },
    showLetterDialog(id, u_name) {
      this.show_letter = true;
      this.editId = id;
      this.editUser = u_name;
      this.clickNum_letter++;
    },
    showSupplierDialog(row) {
      console.log(row);
      this.show_supplier = true;

      this.editId = row.id;
      this.editUser = row.nickname;
      this.shoptitle = row.shop_title;
      this.isSupplier = row.is_supplier;
      this.row = row;
      this.clickNum_supplier++;
    },
    reload() {
      this.getNewsAll();
    },
  },
  beforeCreate() {},
  deactivated() {
    this.searchAll.tid = "";
  },
  created() {
    this.$api.getIndex.getIndex_limits({}).then((res) => {
      if (res.data.code == 200) {
        localStorage.setItem("limit", JSON.stringify(res.data.result)); //存入 参数： 1.调用的值 2.所要存入的数据
        this.$store.commit("setPlugin", res.data.result);
        this.is_open = res.data.result;
        this.get_admin();
      }
    });
    if (this.$route.query) {
      this.queryObj = this.$route.query;
      if (this.$route.query.page) {
        this.currentPage = this.$route.query.page;
        delete this.queryObj.page;
      }
    }
    this.getNewsAll();

    this.$api.getStation.clue_label_lists_all({}).then((res) => {
      if (res.data.code == 200) {
        this.$store.commit("setQuickLabel", res.data.result);
      }
    });
  },

  computed: {},
};
</script>
<style scoped>
.find_btn {
  background: #3a8ee6;
  border-color: #3a8ee6;
  font-weight: 400;

  padding: 2px 8px;
  color: #ffffff;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 5px;
}
</style>
